function searchPOI(keyword) {
    mapObj.plugin(["AMap.PlaceSearch"], function() {  
        var PlaceSearchOptions = {
            city: "北京",
            type: "",
            pageSize: 10,
            pageIndex: 1,
            extensions: "base"
        };  
        var MSearch = new AMap.PlaceSearch(PlaceSearchOptions);
        AMap.event.addListener(MSearch, "complete", keywordSearch_CallBack);
        MSearch.search(keyword);
    });
}

function keywordSearch_CallBack(result) {
    console.log("POI search");
    console.log(result);
    var markers = [];
    var listItemContainer = document.createElement("div");
    listItemContainer.innerHTML = "";
    if (result.poiList && result.poiList.pois && result.poiList.pois.length > 0) {
        for (var i = 0, l = result.poiList.pois.length; i < l; i++) {
            var thisMarker = addMarker(result.poiList.pois[i], i);
            listItemContainer.innerHTML += addPOIListItem(result.poiList.pois[i], i);
            markers.push(thisMarker);
        }
    }
    mapObj.setFitView(markers);
    document.getElementById("itemList").appendChild(listItemContainer);
}

function addPOIListItem(poi, i) {
    var str = "<div class='item' style='border:1px solid blue;'>";
    str += "<p>" + poi.name + "</p>";
    str += "<p>地址：" + poi.address + "</p>";
    str += "<p>电话：" + poi.tel + "</p>";
    str += "</div>";
    return str;
}

function addMarker(poi, i) {
    var marker = new AMap.Marker({                  
        position: poi.location,//基点位置                  
        offset:new AMap.Pixel(-14,-34),//相对于基点的位置                  
        icon:new AMap.Icon({  //复杂图标                  
            size:new AMap.Size(28,37),//图标大小                  
            image:"http://webapi.amap.com/images/custom_a_j.png",//大图地址                  
            imageOffset:new AMap.Pixel(-28 * i,0)//相对于大图的取图位置                  
        })
    });
    marker.setMap(mapObj); 
    return marker;
}